***********************************************************
**** UNFAIR FIGHTS: POWER ASYMMETRY, NASCENT NUCLEAR CAPABILITY, AND PREVENTIVE CONFLICT 
**** SCHUB
**** CMPS REPLICATION FILE 
***********************************************************


***********************
** CONTENTS OVERVIEW
***********************

* (I) Anticipated-shift year results:
  * Models 1-3 from Table 1 (Article)
  * Simulations for Figure 2 (Article)
  * Summary Statistics in upper half of Table 2 (Supporting Information) 
  * Models 1-3 from Table 3 (Supporting Information)
  * Models 1-3 from Table 5 (Supporting Information)
  * Models 1-3 from Table 4 (Supporting Information)
  * Simulations for left panel of Figure 3 (Supporting Information)
  
* (II) Anticipated-shift episode results:
  * Models 4-6 from Table 1 (Article)
  * Summary Statistics from lower half of Table 2 (Supporting Information)
  * Models 4-6 from Table 3 (Supporting Information)
  * Models 4-6 from Table 5 (Supporting Information)

* (III) Politically relevant dyad year results:
  * Summary statistics from Table 6 (Supporting Information)
  * Models 1-6 from Table 7 (Supporting Information)
  * Simulations for Figure 1 (Supporting Information)
  
  
  
*************************************************************************
** (I) Reproduce anticipated-shift year model results (main paper and supporting information)
*************************************************************************

* (A) Set working directory and load data
clear 
use "ShiftYear.dta"

* (B) Produce Models 1-3 from Table 1 (Article)
eststo clear
eststo: quiet logit mid reldef cont duration3 pceyrs pceyrs2 pceyrs3 if forongoing==0, cluster(caseid)
eststo: quiet logit mid relmil cont duration3 pceyrs pceyrs2 pceyrs3 if forongoing==0, cluster(caseid)
eststo: quiet logit mid relcap cont duration3 pceyrs pceyrs2 pceyrs3 if forongoing==0, cluster(caseid)
esttab, se star(* 0.1 ** 0.05 *** 0.01)

* (C) Simulations for Figure 2 (Article)
sort ccode1 ccode2 year

*Egypt (651)-Iraq(645) in 1993 is [658] & US(2)-Iraq(645)in 1993 is [699]
estsimp logit mid reldef cont duration3 pceyrs pceyrs2 pceyrs3 if forongoing==0, cluster(caseid)
setx [658]
setx reldef reldef[658]
simqi, listx
simqi, fd(pr) changex(reldef reldef[658] reldef[56]) level(90)
  
*Median Case
setx median
setx reldef 0.55
simqi, listx
simqi, fd(pr) changex(reldef 0.55 0.95) level(90)
 
* (D) Produce Summmary Statistics in upper half of Table 2 (Supporting Information)
summarize mid force relmil reldef relcap cont duration3 pceyrs pol21 pol22 cont duration3 pceyrs if forongoing==0
sutex mid force reldef relmil relcap cont duration3 pceyrs pol21 pol22 if forongoing==0, minmax

* (E) Produce Models 1-3 from Table 3 (Supporting Information): Alternative Controls
eststo clear
eststo: quiet logit mid reldef pol21 pol22 cont duration3 pceyrs pceyrs2 pceyrs3 if forongoing==0, cluster(caseid)
eststo: quiet logit mid reldef jdem cont duration3 pceyrs pceyrs2 pceyrs3 if forongoing==0, cluster(caseid)
eststo: quiet logit mid reldef jdem cont ally duration3 pceyrs pceyrs2 pceyrs3 if forongoing==0, cluster(caseid)
esttab, se star(* 0.1 ** 0.05 *** 0.01)


* (F) Produce Models 1-3 from Table 5 (Supporting Information): Alternative Outcome Variable
eststo clear
eststo: quiet logit force reldef pol21 pol22 cont duration3 pceyrs pceyrs2 pceyrs3 if forongoing==0, cluster(caseid)
eststo: quiet logit force relmil pol21 pol22 cont duration3 pceyrs pceyrs2 pceyrs3 if forongoing==0, cluster(caseid)
eststo: quiet logit force relcap pol21 pol22 cont duration3 pceyrs pceyrs2 pceyrs3 if forongoing==0, cluster(caseid)
esttab, p star(* 0.1 ** 0.05 *** 0.01)

* (G) Produce Models 1-3 from Table 4 (Supporting Information): Drop Mutual Proliferation Program Dyads
drop if ccode1==2  & ccode2==365 & year>=1945 & year<=1945
drop if ccode1==365  & ccode2==2 & year>=1945 & year<=1945
drop if ccode1==140  & ccode2==160 & year>=1968 & year<=1985
drop if ccode1==160  & ccode2==140 & year>=1968 & year<=1985
drop if ccode1==200  & ccode2==365 & year>=1943 & year<=1949
drop if ccode1==365  & ccode2==200 & year>=1943 & year<=1949
drop if ccode1==630  & ccode2==645 & year>=1983 & year<=1999
drop if ccode1==645  & ccode2==630 & year>=1983 & year<=1999
drop if ccode1==710  & ccode2==732 & year>=1959 & year<=1964
drop if ccode1==732  & ccode2==710 & year>=1959 & year<=1964
drop if ccode1==710  & ccode2==750 & year>=1955 & year<=1964
drop if ccode1==750  & ccode2==710 & year>=1955 & year<=1964
drop if ccode1==710  & ccode2==900 & year>=1956 & year<=1964
drop if ccode1==900  & ccode2==710 & year>=1956 & year<=1964
drop if ccode1==731  & ccode2==732 & year>=1965 & year<=1978
drop if ccode1==732  & ccode2==731 & year>=1965 & year<=1978
drop if ccode1==750  & ccode2==770 & year>=1972 & year<=1987
drop if ccode1==770  & ccode2==750 & year>=1972 & year<=1987

eststo clear
eststo: quiet logit mid reldef cont duration3 pceyrs pceyrs2 pceyrs3 if forongoing==0, cluster(caseid)
eststo: quiet logit mid relmil cont duration3 pceyrs pceyrs2 pceyrs3 if forongoing==0, cluster(caseid)
eststo: quiet logit mid relcap cont duration3 pceyrs pceyrs2 pceyrs3 if forongoing==0, cluster(caseid)
esttab, se star(* 0.1 ** 0.05 *** 0.01)

* (H) Simulations for left panel of Figure 3 (Supporting Information): Binary quarter indicators
clear 
use "ShiftYear.dta"

**quartiles
gen fir=0
replace fir=1 if reldef<0.25
gen sec=0
replace sec=1 if reldef>0.25 & reldef<0.5
gen thi=0
replace thi=1 if reldef>0.5 & reldef<0.75
gen fou=0
replace fou=1 if reldef>0.75


estsimp logit mid sec thi fou cont pol21 pol22 duration3 pceyrs pceyrs2 pceyrs3 if forongoing==0, cluster(caseid)
setx median
setx pceyrs 2 pceyrs2 4 pceyrs3 8 pol21 0 pol22 0
setx sec 0
simqi, listx
setx sec 1
simqi, listx
setx sec 0 thi 1
simqi, listx
setx sec 0 thi 0 fou 1
simqi, listx


*Note: mid=1 if (cwinit==1 & cworig1==1 & cworig2==1)|attack==1 where attack comes from Fuhrmann and Kreps 2010

*************************************************************************
** (II) Reproduce anticipated-shift episode model results (main paper and supporting information)
*************************************************************************

* (A) Set working directory and load data
clear
use "ShiftEpisode.dta"

* (B) Produce Models 4-6 from Table 1 (Article)
eststo clear
eststo: quiet logit mid reldef cont forpossible3 pceyrs if forpossible3>0 
eststo: quiet logit mid relmil cont forpossible3 pceyrs if forpossible3>0 
eststo: quiet logit mid relcap cont forpossible3 pceyrs if forpossible3>0 
esttab, se star(* 0.1 ** 0.05 *** 0.01)

* (C) Produce Summmary Statistics in lower half of Table 2 (Supporting Information)
summarize mid force relmil reldef relcap cont possible3 pceyrs pol21 pol22 if forpossible3>0
sutex mid force reldef relmil relcap cont forpossible3 pceyrs pol21 pol22 if forpossible3>0, minmax

* (D) Produce Models 4-6 from Table 3 (Supporting Information)
eststo clear
eststo: quiet logit mid reldef pol21 pol22 cont forpossible3 pceyrs if forpossible3>0
eststo: quiet logit mid reldef jdem cont forpossible3 pceyrs if forpossible3>0
eststo: quiet logit mid reldef jdem cont ally forpossible3 pceyrs if forpossible3>0
esttab, se star(* 0.1 ** 0.05 *** 0.01)

* (E) Produce  Models 4-6 from Table 5 (Supporting Information)
eststo clear
eststo: quiet logit force reldef pol21 pol22 cont forpossible3 pceyrs if forpossible3>0
eststo: quiet logit force relmil pol21 pol22 cont forpossible3 pceyrs if forpossible3>0
eststo: quiet logit force relcap pol21 pol22 cont forpossible3 pceyrs if forpossible3>0
esttab, se star(* 0.1 ** 0.05 *** 0.01)


*************************************************************************
** (III) Reproduce politically relevant dyad year results (supporting information)
*************************************************************************

* (A) Set working directory and load data
clear
use "PRDyear.dta"

* (B) Produce Summmary Statistics from Table 6 (Supporting Information)
summarize mid force reldef relmil relcap nukeshift cont jdem ally pol21 pol22 pceyrs if forongoing==0 
sutex mid force reldef relmil relcap nukeshift cont jdem ally pol21 pol22 pceyrs if forongoing==0, minmax

* (C) Produce Models 1-6 from Table 7 (Supporting Information)
eststo clear
eststo: quiet relogit mid reldef nukeshift intdef cont pceyrs pceyrs2 pceyrs3 if forongoing==0, cluster(clust)
eststo: quiet relogit mid relmil nukeshift intmil cont pceyrs pceyrs2 pceyrs3 if forongoing==0, cluster(clust)
eststo: quiet relogit mid relcap nukeshift intcap cont pceyrs pceyrs2 pceyrs3 if forongoing==0, cluster(clust)
eststo: quiet relogit mid reldef nukeshift intdef jdem ally cont pceyrs pceyrs2 pceyrs3 if forongoing==0, cluster(clust)
eststo: quiet relogit mid relmil nukeshift intmil jdem ally cont pceyrs pceyrs2 pceyrs3 if forongoing==0, cluster(clust)
eststo: quiet relogit mid relcap nukeshift intcap jdem ally cont pceyrs pceyrs2 pceyrs3 if forongoing==0, cluster(clust)
esttab, se star(* 0.1 ** 0.05 *** 0.01)

* (D) Simulations for Figure 1 (Supporting Information)

*with shifting power
estsimp logit mid reldef nukeshift intdef cont pceyrs pceyrs2 pceyrs3 if forongoing==0, cluster(clust)
setx median
setx reldef 0.55 nukeshift 1 intdef 0.55 pceyrs 1 pceyrs2 1 pceyrs3 1
simqi, listx 
simqi, fd(pr) changex(reldef 0.55 0.95 intdef 0.55 0.95) level (90)

*without shifting power [covariates set to get similar baseline pr(conflict)
setx median
setx reldef 0.55 nukeshift 0 intdef 0 pceyrs 2 pceyrs2 4 pceyrs3 8 cont 1 
simqi, listx
simqi, fd(pr) changex(reldef 0.55 0.95) level(90)



















